<template>
    <el-form :model="coupon" ref="coupon" label-width="100px" class="form-item-inline">
        <el-form-item label="满减规则" prop="name">
            <span>满</span>

                <el-form-item prop="condition"  :rules="[
                        { required: true, message: '请输入满减条件', trigger: 'blur' }
                ]">
                    <el-input-number v-model="coupon.condition" :precision="2" :step="0.1" :min="0" :controls="false"></el-input-number>
                </el-form-item>
            <span>减</span>
                <el-form-item prop="amount" :rules="[
                        { required: true, message: '请输入满减金额', trigger: 'blur' }
                ]">
                    <el-input-number v-model="coupon.amount" :precision="2" :step="0.1" :min="0" :controls="false"></el-input-number>
                </el-form-item>
            <span>元</span>
        </el-form-item>
    </el-form>
</template>

<script>
    export default {
        name: "priceBreakCoupon",
        data(){
            return{
                coupon:{
                    condition:undefined,
                    amount:undefined
                }
            }
        },
        methods:{
            validate() {
                return new Promise(((resolve) => {
                    this.$refs['coupon'].validate((valid) => {
                        if (valid) {
                            resolve(valid);
                        } else {
                            resolve(false)
                        }
                    });
                }));
            },
            getValue() {
                return this.coupon
            },
            setValue(data) {
                this.coupon={...this.coupon,...data}
            }
        }
    }
</script>

<style scoped>
    .form-item-inline >>>.el-form-item__content{
        display: flex;
    }
</style>
